package com.walleipt.demo.aop.methodInterceptorDemo;

import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

public class MyMethodInvocation implements MethodInvocation {

	List<MethodInterceptor> methodInterceptors =  new ArrayList<MethodInterceptor>() ;
	int index = -1 ;
	
	public MyMethodInvocation( List<MethodInterceptor> methodInterceptors ) {
		this.methodInterceptors = methodInterceptors ;
	}
	
	public Object[] getArguments() {
		// TODO Auto-generated method stub
		return null;
	}

	public Object proceed() throws Throwable {

		++this.index;
		if ( this.index == 3 ) return null ;
		
		MethodInterceptor methodInterceptor = methodInterceptors.get(this.index);
		return methodInterceptor.invoke(this);
	}

	public Object getThis() {
		// TODO Auto-generated method stub
		return null;
	}

	public AccessibleObject getStaticPart() {
		// TODO Auto-generated method stub
		return null;
	}

	public Method getMethod() {
		// TODO Auto-generated method stub
		return null;
	}

}
